<!DOCTYPE html>
<html>
<head>
    <title>收费项目管理</title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="../Css/bootstrap.css" />
    <link rel="stylesheet" type="text/css" href="../Css/bootstrap-responsive.css" />
    <link rel="stylesheet" type="text/css" href="../Css/style.css" />
    <script type="text/javascript" src="../Js/jquery.js"></script>
    <script type="text/javascript" src="../Js/bootstrap.js"></script>
    <script type="text/javascript" src="../Js/ckform.js"></script>
    <script type="text/javascript" src="../Js/common.js"></script>

    <style type="text/css">
        body {
            padding-bottom: 40px;
        }
        .sidebar-nav {
            padding: 9px 0;
        }

        @media (max-width: 980px) {
            /* Enable use of floated navbar text */
            .navbar-text.pull-right {
                float: none;
                padding-left: 5px;
                padding-right: 5px;
            }
        }


    </style>
    <script type="text/javascript">
	
    	function checkall(){
			var alls=document.getElementsByName("check");
			var ch=document.getElementById("checkall");
			if(ch.checked){
				for(var i=0;i<alls.length;i++){
					alls[i].checked=true;	
				}	
			}else{
				for(var i=0;i<alls.length;i++){
					alls[i].checked=false;	
				}	
			}
		}
		function delAll(){
			var alls=document.getElementsByName("check");
			var ids=new Array();
			for(var i=0;i<alls.length;i++){
				if(alls[i].checked){
					ids.push(alls[i].value);
				}		
			}
			if(ids.length>0){
				if(confirm("确认操作?")){
					alert("成功!");
				}
			}else{
				alert("请选中要操作的项");
			}
		}
    </script>
</head>
<body>
   
<div  class="definewidth m20">
<table class="table table-bordered table-hover definewidth m10">
    <tr>
        <td width="10%" class="tableleft">病历号：</td>
        <td><input type="text" id="behId" name="behId" value=""/></td>
		
        <td width="10%" class="tableleft">姓名：</td>
        <td><input type="text" id="behName" name="behName" value=""/></td>
    </tr>
    <tr>
		
		
		  <td colspan="4">
			<center>
				<button  class="btn btn-primary" type="button" onclick="queryList(1)">查询</button>
				<button type="reset" id="res" class="btn btn-primary" >清空</button>
			</center>
        </td>
    </tr>
</table>
</div>
<table class="table table-bordered table-hover definewidth m10" >
   <thead>
    <tr>
        <th>病历号</th>
        <th>姓名</th>
        <th>住院日期</th>        
        <th>操作</th>
    </tr>
    </thead>
    <tbody id="tbody">
	     <tr>
<!--            <td style="vertical-align:middle;">1103</td>-->
<!--            <td style="vertical-align:middle;">黄飞鸿</td>-->
<!--            <td style="vertical-align:middle;">2015-01-04 10:34:33</td>-->
<!--            <td style="vertical-align:middle;">-->
<!--				<a href="account-look2.html">详情</a>-->
<!--				<a href="charge-new.html">添加收费项</a>-->
<!--			</td>-->
        </tr>
    </tbody>
  </table>
  
  <table class="table table-bordered table-hover definewidth m10" >
  	<tr><th colspan="5">
<!--        <div class="inline pull-right page">-->
<!--          <a href='#' >第一页</a> <a href='#'>上一页</a>    -->
<!--            <span class='current'>1</span><a href='#'>2</a>-->
<!--            <a href='/chinapost/index.php?m=Label&a=index&p=3'>3</a>-->
<!--            <a href='#'>4</a>-->
<!--            <a href='#'>5</a>  <a href='#' >下一页</a> <a href='#' >最后一页</a>-->
<!--		  &nbsp;&nbsp;&nbsp;共<span class='current'>32</span>条记录<span class='current'> 1/33 </span>页-->
<!--		  </div>-->
<!--		-->
        <div id="pageInfo-box" class="inline pull-right page">
        </div>
		 </th>
    </tr>
  </table>
  
</body>
</html>
<script>
    let bName =null;
    $(function () {
        queryList(globalPageNum);
        // 监听清空
        $("#res").on("click",function(){
            $("#behId").val("");
            $("#behName").val("");
            queryList(1);
        })
    });
    queryList = function(pageNum){
        let behId = $("#behId").val();
        let behName = $("#behName").val();
        layer.load(0);
        $.ajax({
            type: "GET",
            url: origin + "/ckcharge/list/?pageNum="+pageNum+"&pageSize="+globalPageSize,
            data:{
                behId:behId,
                behName:behName,
                jwtToken:jwtToken
            },
            xhrFields: {
                withCredentials: true
            },
            crossDomain: true,
            success: function (data) {
                layer.closeAll();
                console.log(data);
                if(data.code == 200){
                    // 填充分页
                    fillPageData(data.obj);
                    // 更新当前页全局变量
                    globalPageNum = data.obj.pageNum;
                    // 更新每页条数全局变量
                    globalPageSize = data.obj.pageSize;
                    // 填充内容
                    loadDate(data);
                }else{
                }
            }
            // TODO: 后端拦截ajax请求进行登陆跳转需要前端相互配合, 每一个ajax请求都需要加上以下的代码
            ,complete : function(xhr, status) {
                myComplete(xhr, status);
            }
        });
    }
    function loadDate(data) {
        let list = data.obj.list;

        let str = "";
        for (let i =0;i<list.length;i++){
            let obj = list[i];
            let id=obj.behId==null?'':obj.behId;
            let name=obj.behName==null?'':obj.behName;
            let nameuri = encodeURI(name);
            bName=name;
            let createtime=obj.behCreateTime==null?'':obj.behCreateTime;
            str+='<tr>' +
                '            <td>'+id+'</td>' +
                '            <td>'+name+'</td>' +
                '            <td>'+createtime+'</td>' +
                '            <td style="vertical-align:middle;">'+
                '<a href="#" onclick="query('+id+')" >'+"详情&nbsp;&nbsp;"+'</a>'+
                '<a href="#" onclick="query1('+id+',\''+nameuri+'\')">'+"添加收费项"+'</a>'+
                '            </td>'
            '</tr>'

        }
        $("#tbody").html($(str));

    }
    function query(id) {
        // window.location.href="/hospital/charge-edit1.html?chapId="+id;
        window.location.href="account-look2.html?behId="+id+
            "&globalPageNum" + globalPageNum + "&globalPageSize" + globalPageSize;
    }
    function query1(id,nameuri) {
        // window.location.href="/hospital/charge-edit1.html?chapId="+id;
        window.location.href="charge-new.html?behId="+id+"&nameuri="+nameuri.replaceAll("%","_")+
            "&globalPageNum" + globalPageNum + "&globalPageSize" + globalPageSize;
    }
</script>